package com.amikomgamedev.panjatpinang.states;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.ui.activity.SimpleBaseGameActivity;

import android.content.Intent;
import android.view.KeyEvent;

import com.amikomgamedev.panjatpinang.Data;
import com.amikomgamedev.panjatpinang.Define;
import com.amikomgamedev.panjatpinang.Utils;

/*
 * AndEngineGamePanjatPinang
 * State_Help.java
 * Pratama Wijaya
 * set.mnemonix@gmail.com
 * 1:28:34 AM , Aug 11, 2012
 */

public class State_Help extends SimpleBaseGameActivity implements Data, Define {
	private Camera				mCamera;
	private Scene				mScene;
	private BitmapTextureAtlas	texBg;
	private ITextureRegion		treBg;
	private Sprite				sprBg;

	@Override
	public EngineOptions onCreateEngineOptions() {
		// TODO Auto-generated method stub
		mCamera = new Camera(0, 0, GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
		EngineOptions en = new EngineOptions(true,
				ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(
						GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT), mCamera);
		return en;
	}

	@Override
	protected void onCreateResources() {
		// TODO Auto-generated method stub
		texBg = new BitmapTextureAtlas(this.getTextureManager(), 512, 512,
				TextureOptions.BILINEAR_PREMULTIPLYALPHA);
		treBg = BitmapTextureAtlasTextureRegionFactory.createFromAsset(texBg,
				this.getAssets(), IMG_BG_HELP, 0, 0);
		texBg.load();

	}

	@Override
	protected Scene onCreateScene() {
		// TODO Auto-generated method stub
		mScene = new Scene();
		sprBg = new Sprite(0, 0, treBg, mEngine.getVertexBufferObjectManager());

		mScene.attachChild(sprBg);
		return mScene;
	}

	@Override
	public boolean onKeyDown(final int keyCode, final KeyEvent event) {
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			Utils.TRACE("exit pake back");
			Intent menu = new Intent(State_Help.this, State_MainMenu.class);
			startActivity(menu);
			finish();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	}

}
